home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / ClassEditor.0.4 / Source / RZBrowserCell.subproj / RZRefCountedList.m < prev    next >
Encoding:
Text File  |  1995-04-04  |  744 b   |  51 lines

  1. /* 
  2.  * RZRefCountedList - a List that implements reference counting
  3.  *
  4.  * You may freely copy, distribute and reuse the code in this example.
  5.  * This code is provided AS IS without warranty of any kind, expressed 
  6.  * or implied, as to its fitness for any particular use.
  7.  *
  8.  * Copyright 1995 Ralph Zazula (rzazula@next.com).  All Rights Reserved.
  9.  *
  10.  */
  11.  
  12. #import "RZRefCountedList.h"
  13.  
  14. @implementation RZRefCountedList
  15.  
  16. - init
  17. {
  18.     if(self = [super init]) {
  19.         refs = 1;
  20.     }
  21.     return self;
  22. }
  23.  
  24. - addReference
  25. {
  26.     refs++;
  27.     return self;
  28. }
  29.  
  30. - free
  31. {
  32.     refs--;
  33.     if (refs > 0) return self;
  34.     return [super free];
  35. }
  36.  
  37. - (unsigned int)references
  38. {
  39.     return refs;
  40. }
  41.  
  42. - freeObjects
  43. {
  44.     if(refs == 1) {
  45.         return [super freeObjects];
  46.     }
  47.     return self;
  48. }
  49.  
  50. @end
  51.